﻿@model CustomerSettingsModel
@using Nop.Core.Infrastructure;
@using SpotsHub.Gateway.Models.Customer;
@{
    Layout = "~/Views/Shared/_MyHUB.cshtml";

    //title
    ViewBag.Title = T("Account.CustomerSettings");

    var gridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Customers.CustomerSettings>().GridPageSize;
    if (gridPageSize <= 0)
    {
        gridPageSize = 10;
    }
}

@section left
{
    @Html.Partial("MyAccountNavigation", Model.NavigationModel, new ViewDataDictionary())
}

<div class="page-settings">

    <h1 class="section-title">@T("Account.CustomerSettings")</h1>
    
    <div class="my-hub-body section-wrapper">
        @Html.Action("RenderMessages", "Common")
        @using (Html.BeginForm("BuyMembership", "Customer"))
        {
            <div class="row">
                <div class="col-xs-12 col-md-8">
                    <div role="tabpanel">

                        <!-- Nav tabs -->
                        <ul class="nav nav-tabs" role="tablist">
                            <li role="presentation"><a href="#regionlanguage" aria-controls="home" role="tab" data-toggle="tab" data-type="@((int)CustomerSettingsType.RegionAndLanguages)">Region and Languages</a></li>
                            <li role="presentation"><a href="#emailpreference" aria-controls="profile" role="tab" data-toggle="tab" data-type="@((int)CustomerSettingsType.EmailPreferences)">Email Preferences</a></li>
                        </ul>

                        <!-- Tab panes -->
                        <div class="tab-content">
                            <div role="tabpanel" class="tab-pane" id="regionlanguage">
                                <h2 class="mobile-title">Region and Languages</h2>
                                <h3>Region</h3>
                                <p>Region selected will affect the products you can see on SpotHUB. Shoppers may not purchase products from different regions in one order. Your shopping cart will be cleared after the region is changed.</p>
                                @Html.DropDownListFor(model => model.SelectedRegion, Model.AvailableRegions.Take(1), new { Class = "form-control" })

                                <h3>Language</h3>
                                <p>You may select a display language from our selection of languages. Product descriptions unavailable in the selected language will be displayed in English.</p>
                                @Html.DropDownListFor(model => model.SelectedLanguage, Model.AvailableLanguages, new { Class = "form-control" })

                                <h3>Time Zone</h3>
                                <p>Time zone selected will affect the timestamping of your orders on SpotsHUB. </p>
                                @Html.DropDownListFor(model => model.SelectedTimeZone, Model.AvailableTimeZones, new { Class = "form-control" })

                                <div class="clear"></div>
                                <div class="buttons">
                                    <div class="row">
                                        <div class="col-xs-12 col-md-6 col-md-offset-6">
                                            <input type="button" value="@T("Common.Save")" class="btn btn-normal form-control" data-action="submit" data-name="@Html.NameFor(model => model.SettingsType)" data-value="@((int)CustomerSettingsType.RegionAndLanguages)" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div role="tabpanel" class="tab-pane" id="emailpreference">
                                <h2 class="mobile-title">Email Preferences</h2>
                                <h3>Please Email Me:</h3>
                                <p>Simply check Yes or NO and click Save to change your email preference.</p>
                                <div class="table-wrapper">
                                    <table class="table table-striped table-condensed">
                                        <tbody>
                                            <tr>
                                                <td></td>
                                                <td>Yes</td>
                                    
                                                <td>No</td>
                                            </tr>
                                            <tr>
                                                <td>@Html.LabelFor(model => model.EmailPreferences.LogisticsInvoicePaid)</td>
                                                <td>@Html.RadioButtonFor(model => model.EmailPreferences.LogisticsInvoicePaid, "True")</td>
                                                <td>@Html.RadioButtonFor(model => model.EmailPreferences.LogisticsInvoicePaid, "False")</td>
                                            </tr>
                                            <tr>
                                                <td>@Html.LabelFor(model => model.EmailPreferences.LogisticsInvoiceReady)</td>
                                                <td>@Html.RadioButtonFor(model => model.EmailPreferences.LogisticsInvoiceReady, "True")</td>
                                                <td>@Html.RadioButtonFor(model => model.EmailPreferences.LogisticsInvoiceReady, "False")</td>
                                            </tr>
                                            <tr>
                                                <td>@Html.LabelFor(model => model.EmailPreferences.LogisticsOrderPlaced)</td>
                                                <td>@Html.RadioButtonFor(model => model.EmailPreferences.LogisticsOrderPlaced, "True")</td>
                                                <td>@Html.RadioButtonFor(model => model.EmailPreferences.LogisticsOrderPlaced, "False")</td>
                                            </tr>
                                            <tr>
                                                <td>@Html.LabelFor(model => model.EmailPreferences.LogisticsDelivered)</td>
                                                <td>@Html.RadioButtonFor(model => model.EmailPreferences.LogisticsDelivered, "True")</td>
                                                <td>@Html.RadioButtonFor(model => model.EmailPreferences.LogisticsDelivered, "False")</td>
                                            </tr>
                                            <tr>
                                                <td>@Html.LabelFor(model => model.EmailPreferences.LogisticsFailedPickup)</td>
                                                <td>@Html.RadioButtonFor(model => model.EmailPreferences.LogisticsFailedPickup, "True")</td>
                                                <td>@Html.RadioButtonFor(model => model.EmailPreferences.LogisticsFailedPickup, "False")</td>
                                            </tr>
                                            <tr>
                                                <td>@Html.LabelFor(model => model.EmailPreferences.CommerceOrderPlaced)</td>
                                                <td>@Html.RadioButtonFor(model => model.EmailPreferences.CommerceOrderPlaced, "True")</td>
                                                <td>@Html.RadioButtonFor(model => model.EmailPreferences.CommerceOrderPlaced, "False")</td>
                                            </tr>
                                            <tr>
                                                <td>@Html.LabelFor(model => model.EmailPreferences.NewsLetterSubscription)</td>
                                                <td>@Html.RadioButtonFor(model => model.EmailPreferences.NewsLetterSubscription, "True")</td>
                                                <td>@Html.RadioButtonFor(model => model.EmailPreferences.NewsLetterSubscription, "False")</td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>



                                @*<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                                    <input type="checkbox" name="AllLogistics" id="AllLogistics" />
                                    <label for="AllLogistics">@T("Account.EmailPreference.ShippingOrderMessages")</label>
                                    <ul class="allLogistics">
                                        <li>
                                            @Html.CheckBoxFor(model => model.EmailPreferences.LogisticsInvoicePaid)
                                            @Html.LabelFor(model => model.EmailPreferences.LogisticsInvoicePaid)
                                        </li>
                                        <li>
                                            @Html.CheckBoxFor(model => model.EmailPreferences.LogisticsInvoiceReady)
                                            @Html.LabelFor(model => model.EmailPreferences.LogisticsInvoiceReady)
                                        </li>
                                        <li>
                                            @Html.CheckBoxFor(model => model.EmailPreferences.LogisticsOrderPlaced)
                                            @Html.LabelFor(model => model.EmailPreferences.LogisticsOrderPlaced)
                                        </li>
                                        <li>
                                            @Html.CheckBoxFor(model => model.EmailPreferences.LogisticsDelivered)
                                            @Html.LabelFor(model => model.EmailPreferences.LogisticsDelivered)
                                        </li>
                                        <li>
                                            @Html.CheckBoxFor(model => model.EmailPreferences.LogisticsFailedPickup)
                                            @Html.LabelFor(model => model.EmailPreferences.LogisticsFailedPickup)
                                        </li>
                                    </ul>
                                </div>
                                <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                                    <input type="checkbox" name="AllCommerce" id="AllCommerce" />
                                    <label for="AllCommerce">@T("Account.EmailPreference.ShoppingMessages")</label>
                                    <ul class="allCommerce">

                                        <li>
                                            @Html.CheckBoxFor(model => model.EmailPreferences.CommerceOrderPlaced)
                                            @Html.LabelFor(model => model.EmailPreferences.CommerceOrderPlaced)
                                        </li>
                                    </ul>
                                    @Html.CheckBoxFor(model => model.EmailPreferences.NewsLetterSubscription)
                                    @Html.LabelFor(model => model.EmailPreferences.NewsLetterSubscription)
                                </div>*@
                                <div class="clear"></div>
                                <div class="buttons">
                                    <div class="row">
                                        <div class="col-xs-12 col-md-6 col-md-offset-6">
                                            <input type="button" value="@T("Common.Save")" class="btn btn-normal form-control" data-action="submit" data-name="@Html.NameFor(model => model.SettingsType)" data-value="@((int)CustomerSettingsType.EmailPreferences)" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        }
    </div>
</div>
<script>
    $(document).ready(function () {
        var activeType = "@Model.SettingsType";
        if (activeType == "") {
            $(".nav-tabs li:first-child a").tab("show");
        } else {
            $(".nav-tabs li a[data-type=" + activeType + "]").tab("show");
        }
    });
    $("input[type=button]").live("click", function () {
        if ($(this).attr("data-action") == "submit") {
            $("#settingsSubmit").remove();
            var form = $(this).closest("form");
            form.append("<input id='settingsSubmit' type='hidden' name='" + $(this).attr("data-name") + "' value='" + $(this).attr("data-value") + "'>");
            form.submit();
            $("#settingsSubmit").remove();
        }
    });
</script>